package dao.impl;

import dao.BaseDao;
import dao.FollowDao;

import java.sql.ResultSet;

public class FollowDaoImpl extends BaseDao implements FollowDao {

    @Override
    public int getFollowCount(int uid) {
        int i=0;
        ResultSet rs=null;
        String sql=" select count(*) from follow where uid=? ";
        try {
            rs=executeQuery(sql,uid);
            while (rs.next()){
                i=rs.getInt("count(*)");
            }

        }catch (Exception e){
            e.printStackTrace();
        }finally {
            closeAll(conn,null,rs);
        }
        return i;

    }

    @Override
    public int getFansCount(int uid) {
        int i=0;
        ResultSet rs=null;
        String sql=" select count(*) from follow where followedUid=? ";
        try {
            rs=executeQuery(sql,uid);
            while (rs.next()){
                i=rs.getInt("count(*)");
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            closeAll(conn,null,rs);
        }
        return i;

    }
}
